<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<button>button</button>
<script>
  var btn = document.querySelector('button');

  btn.addEventListener('click', f);
  function f() {
    alert('you click me');
    btn.removeEventListener('click',f)
  }
</script>
</body>
</html>